
function chainWebpackConfig(config) {
  // it can improve the speed of the first screen, it is recommended to turn on preload
  // config.plugin('preload').tap(() => [
  //   {
  //     rel: 'preload',
  //     // to ignore runtime.js
  //     // https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/config/app.js#L171
  //     fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
  //     include: 'initial'
  //   }
  // ])

  // // // when there are many pages, it will cause too many meaningless requests
  // config.plugins.delete('prefetch')
  // // 修复HMR
  // config.resolve.symlinks(true)

  // config
  // .plugin('html')
  // .tap(args => {
  //   args[0].title= '以豹制豹的项目'
  //   return args
  // })
  config.optimization.splitChunks({
    chunks: 'all',
    cacheGroups: {
      // defaultVendors: {
      //   reuseExistingChunk: true,
      // },
      vue: {
        name: 'vue',
        test: /[\\/]node_modules[\\/]vue[\\/]/,
        priority: -10
      },
      vuex: {
        name: 'vuex',
        test: /[\\/]node_modules[\\/]vuex[\\/]/,
        priority: -10
      },
      'vue-router': {
        name: 'vue-router',
        test: /[\\/]node_modules[\\/]vue-router[\\/]/,
        priority: -10,
      },
      'element-ui': {
        name: 'element-ui',
        test: /[\\/]node_modules[\\/]element-ui[\\/]/,
        priority: -10
      },
      'swiper': {
        name: 'swiper',
        test: /[\\/]node_modules[\\/]element-ui[\\/]/,
        priority: -10
      },
      'echarts': {
        name: 'echarts',
        test: /[\\/]node_modules[\\/]echarts[\\/]/,
        priority: -10
      },
      'vendors': {
        name: 'vendors',
        test: /[\\/]node_modules[\\/]/,
        priority: -20
      }
    }
  })
}

module.exports = chainWebpackConfig
